import { NextResponse } from 'next/server'
import { prisma } from '@/lib/prisma'

// 温度校准相关的常量配置
const CALIBRATION_CONFIG = {
  CALIBRATION_PERIOD_DAYS: 2,   // 校准时间跨度（天）- 改为2天
  MIN_DATA_POINTS: 16,          // 最小数据点数量（2天睡眠时段，30分钟采集一次 = 32个点，设为16保证灵活性）
  MIN_SLEEP_HOURS: 4,           // 最小睡眠时间跨度（小时）
  MIN_TEMP: 30,                 // 生理合理温度下限（摄氏度）- 参考activity-analysis
  MAX_TEMP: 45,                 // 生理合理温度上限（摄氏度）- 参考activity-analysis
  OUTLIER_STD_MULTIPLIER: 2.5,  // 离群值标准差倍数
  BASELINE_SAMPLE_SIZE: 5,      // 建立基线所需的有效期间数量（5个2天期间 = 10天数据）
  BASELINE_TYPE: 'skin_temp',   // 基线类型标识
  BASELINE_UPDATE_DAYS: 30,     // 基线更新频率（天）
  CORE_TEMP_BASELINE: 37.0,     // 标准核心体温基线（摄氏度）
  ANCHOR_OFFSET_SAMPLE_SIZE: 3  // 计算锚定偏移量所需的样本数量（3个2天期间）
}

/**
 * 判断是否为睡眠时段（22:00-06:00）- 复用activity-analysis逻辑
 */
function isSleepPeriod(timestamp: number): boolean {
  const time = new Date(timestamp)
  const hour = time.getHours()
  return hour >= 22 || hour <= 6
}

/**
 * 处理温度数据 - 复用temperature-chart逻辑
 */
function processTemperatureData(logs: any[]): Array<{timestamp: number, temperature: number}> {
  const temperaturePoints: Array<{timestamp: number, temperature: number}> = []
  
  logs.forEach((log) => {
    try {
      const logData = typeof log.data === 'string' ? JSON.parse(log.data) : log.data

      // 处理时间戳：优先使用logData中的ts，如果没有则使用log的timestamp
      let timestamp = parseInt(logData.ts) || parseInt(log.timestamp)
      
      // 如果时间戳是10位（秒级），转换为13位（毫秒级）
      if (timestamp < 10000000000) {
        timestamp = timestamp * 1000
      }
      
      // 检查时间戳是否在合理范围内（2020-2070年之间）
      const minValidTimestamp = new Date('2020-01-01').getTime()
      const maxValidTimestamp = new Date('2070-12-31').getTime()
      
      if (timestamp < minValidTimestamp || timestamp > maxValidTimestamp) {
        console.warn('跳过无效时间戳:', {
          originalTimestamp: logData.ts || log.timestamp,
          convertedTimestamp: timestamp,
          timestampDate: new Date(timestamp).toISOString()
        })
        return
      }
      
      // 提取温度数据 - 使用activity-analysis的温度范围验证
      const temperatureValue = parseFloat(logData.temperature) || 0
      
      if (temperatureValue > CALIBRATION_CONFIG.MIN_TEMP && temperatureValue < CALIBRATION_CONFIG.MAX_TEMP) {
        temperaturePoints.push({
          timestamp,
          temperature: temperatureValue
        })
      }
    } catch (error) {
      console.error('解析温度数据失败:', error)
    }
  })

  return temperaturePoints.sort((a, b) => a.timestamp - b.timestamp)
}

/**
 * 过滤睡眠时段的温度数据
 */
function filterSleepTemperatureData(temperatureData: Array<{timestamp: number, temperature: number}>) {
  return temperatureData.filter(point => isSleepPeriod(point.timestamp))
}

/**
 * 模块一：数据预处理与有效性验证
 */
function validateSleepTemperatureData(temperatureData: Array<{timestamp: number, temperature: number}>) {
  console.log('开始睡眠温度数据验证，原始数据点数量:', temperatureData.length)
  
  // 步骤1：最小数据点数检查
  if (temperatureData.length < CALIBRATION_CONFIG.MIN_DATA_POINTS) {
    return {
      isValid: false,
      reason: `睡眠时段温度数据点不足，需要至少${CALIBRATION_CONFIG.MIN_DATA_POINTS}个点，实际只有${temperatureData.length}个`
    }
  }

  // 步骤2：检查睡眠时段数据的时间分布
  const sleepHours = new Set()
  temperatureData.forEach(point => {
    const hour = new Date(point.timestamp).getHours()
    sleepHours.add(hour)
  })
  
  console.log('睡眠时段小时分布:', Array.from(sleepHours).sort())
  
  // 确保有足够的睡眠时段覆盖
  if (sleepHours.size < CALIBRATION_CONFIG.MIN_SLEEP_HOURS) {
    return {
      isValid: false,
      reason: `睡眠时段覆盖不足，需要至少${CALIBRATION_CONFIG.MIN_SLEEP_HOURS}个小时，实际只有${sleepHours.size}个小时`
    }
  }

  // 步骤3：离群值剔除（温度数据已经在processTemperatureData中进行了基本范围过滤）
  // 计算平均值和标准差进行相对范围过滤
  const temperatures = temperatureData.map(point => point.temperature)
  const avg = temperatures.reduce((sum, temp) => sum + temp, 0) / temperatures.length
  const variance = temperatures.reduce((sum, temp) => sum + Math.pow(temp - avg, 2), 0) / temperatures.length
  const stdDev = Math.sqrt(variance)
  
  const lowerBound = avg - CALIBRATION_CONFIG.OUTLIER_STD_MULTIPLIER * stdDev
  const upperBound = avg + CALIBRATION_CONFIG.OUTLIER_STD_MULTIPLIER * stdDev
  
  const validData = temperatureData.filter(point => 
    point.temperature >= lowerBound && 
    point.temperature <= upperBound
  )
  
  console.log('离群值过滤后数据点数量:', validData.length)
  console.log('统计信息:', { 
    avg: avg.toFixed(2), 
    stdDev: stdDev.toFixed(2), 
    lowerBound: lowerBound.toFixed(2), 
    upperBound: upperBound.toFixed(2) 
  })

  // 最终检查剩余数据点数量
  if (validData.length < CALIBRATION_CONFIG.MIN_DATA_POINTS) {
    return {
      isValid: false,
      reason: `离群值过滤后数据点不足，需要至少${CALIBRATION_CONFIG.MIN_DATA_POINTS}个点，实际只有${validData.length}个`
    }
  }

  return {
    isValid: true,
    validData,
    avgTemp: validData.reduce((sum, point) => sum + point.temperature, 0) / validData.length
  }
}

/**
 * 计算锚定偏移量
 * 锚定偏移量 = 标准核心体温 - 设备测量的平均皮肤温度
 */
function calculateAnchorOffset(deviceAvgTemp: number): number {
  return CALIBRATION_CONFIG.CORE_TEMP_BASELINE - deviceAvgTemp
}

// 移除核心体温计算函数 - 由前端处理

/**
 * 检查基线是否需要更新
 */
async function shouldUpdateBaseline(baseline: any): Promise<boolean> {
  if (!baseline.last_updated) return true
  
  const lastUpdated = new Date(baseline.last_updated)
  const now = new Date()
  const daysSinceUpdate = Math.floor((now.getTime() - lastUpdated.getTime()) / (1000 * 60 * 60 * 24))
  
  return daysSinceUpdate >= (baseline.update_frequency_days || CALIBRATION_CONFIG.BASELINE_UPDATE_DAYS)
}

/**
 * 记录偏移量历史
 */
async function recordOffsetHistory(
  userId: number,
  baselineId: bigint,
  anchorOffset: number,
  baselineTemp: number,
  effectiveStartDate: Date
): Promise<void> {
  // 结束当前有效的偏移量记录
  await prisma.temperature_offset_history.updateMany({
    where: {
      user_id: userId,
      is_current: true
    },
    data: {
      effective_end_date: effectiveStartDate,
      is_current: false
    }
  })

  // 创建新的偏移量历史记录
  await prisma.temperature_offset_history.create({
    data: {
      user_id: userId,
      baseline_id: baselineId,
      anchor_offset: anchorOffset,
      baseline_temp: baselineTemp,
      effective_start_date: effectiveStartDate,
      is_current: true
    }
  })

  console.log(`偏移量历史已记录: ${anchorOffset.toFixed(2)}°C，生效时间: ${effectiveStartDate.toISOString()}`)
}

/**
 * 更新现有基线
 */
async function updateExistingBaseline(
  userId: number, 
  baselineId: bigint, 
  newBaselineValue: number, 
  newAnchorOffset: number,
  endDate: string,
  sampleSize: number
): Promise<void> {
  const startDate = new Date(endDate)
  startDate.setDate(startDate.getDate() - (sampleSize * CALIBRATION_CONFIG.CALIBRATION_PERIOD_DAYS))
  
  await prisma.user_health_baselines.update({
    where: { id: baselineId },
    data: {
      baseline_value: newBaselineValue,
      anchor_offset: newAnchorOffset,
      calculation_start_date: startDate,
      calculation_end_date: new Date(endDate),
      sample_size: sampleSize,
      last_updated: new Date()
    }
  })

  // 记录偏移量历史
  await recordOffsetHistory(userId, baselineId, newAnchorOffset, newBaselineValue, new Date())
  
  console.log(`基线已更新: 新基线值=${newBaselineValue.toFixed(2)}°C, 锚定偏移量=${newAnchorOffset.toFixed(2)}°C`)
}

/**
 * 模块二：个人基线建立与维护（增强版）
 */
async function getOrCreateBaseline(userId: number, periodAvgTemp: number, endDate: string) {
  // 查询用户当前激活的基线
  const activeBaseline = await prisma.user_health_baselines.findFirst({
    where: {
      user_id: userId,
      baseline_type: CALIBRATION_CONFIG.BASELINE_TYPE,
      is_active: true
    }
  })

  if (activeBaseline) {
    // 检查基线是否需要更新
    const needsUpdate = await shouldUpdateBaseline(activeBaseline)
    
    if (needsUpdate) {
      console.log('基线需要更新，重新计算...')
      
      // 重新计算基线和锚定偏移量
      const historicalPeriods: number[] = []
      const periodsNeeded = CALIBRATION_CONFIG.ANCHOR_OFFSET_SAMPLE_SIZE // 使用较少的样本进行更新
      
      for (let i = 0; i < periodsNeeded; i++) {
        const periodEndDate = new Date(endDate)
        periodEndDate.setDate(periodEndDate.getDate() - (i * CALIBRATION_CONFIG.CALIBRATION_PERIOD_DAYS))
        
        const periodStartDate = new Date(periodEndDate)
        periodStartDate.setDate(periodStartDate.getDate() - CALIBRATION_CONFIG.CALIBRATION_PERIOD_DAYS)
        
        const periodLogs = await prisma.yh_logs.findMany({
          where: {
            user_id: userId,
            type: 'temperature',
            deleted_at: 0,
            timestamp: {
              gte: BigInt(periodStartDate.getTime()),
              lt: BigInt(periodEndDate.getTime())
            }
          },
          orderBy: {
            timestamp: 'asc'
          }
        })
        
        if (periodLogs.length > 0) {
          const processedData = processTemperatureData(periodLogs)
          const sleepData = filterSleepTemperatureData(processedData)
          const validation = validateSleepTemperatureData(sleepData)
          
          if (validation.isValid && validation.avgTemp) {
            historicalPeriods.push(validation.avgTemp)
          }
        }
      }
      
      // 包含当前期间
      historicalPeriods.push(periodAvgTemp)
      
      if (historicalPeriods.length >= CALIBRATION_CONFIG.ANCHOR_OFFSET_SAMPLE_SIZE) {
        const newBaselineValue = historicalPeriods.reduce((sum, avg) => sum + avg, 0) / historicalPeriods.length
        const newAnchorOffset = calculateAnchorOffset(newBaselineValue)
        
        // 更新现有基线
        await updateExistingBaseline(
          userId,
          activeBaseline.id,
          newBaselineValue,
          newAnchorOffset,
          endDate,
          historicalPeriods.length
        )
        
        return {
          hasBaseline: true,
          baselineValue: newBaselineValue,
          anchorOffset: newAnchorOffset,
          isUpdated: true
        }
      } else {
        console.log('更新基线的数据不足，继续使用现有基线')
      }
    }
    
    return {
      hasBaseline: true,
      baselineValue: activeBaseline.baseline_value,
      anchorOffset: activeBaseline.anchor_offset || 0,
      isUpdated: false
    }
  }

  // 没有基线，需要建立新基线
  // 查询用户最近足够的历史数据来建立基线
  const historicalPeriods: number[] = []
  
  // 计算需要多少个2周期间来建立基线
  const periodsNeeded = CALIBRATION_CONFIG.BASELINE_SAMPLE_SIZE
  
  for (let i = 0; i < periodsNeeded; i++) {
    const periodEndDate = new Date(endDate)
    periodEndDate.setDate(periodEndDate.getDate() - (i * CALIBRATION_CONFIG.CALIBRATION_PERIOD_DAYS))
    
    const periodStartDate = new Date(periodEndDate)
    periodStartDate.setDate(periodStartDate.getDate() - CALIBRATION_CONFIG.CALIBRATION_PERIOD_DAYS)
    
    console.log(`查询历史期间 ${i + 1}:`, {
      start: periodStartDate.toISOString().split('T')[0],
      end: periodEndDate.toISOString().split('T')[0]
    })
    
    // 获取该期间的温度数据
    const periodLogs = await prisma.yh_logs.findMany({
      where: {
        user_id: userId,
        type: 'temperature',
        deleted_at: 0,
        timestamp: {
          gte: BigInt(periodStartDate.getTime()),
          lt: BigInt(periodEndDate.getTime())
        }
      },
      orderBy: {
        timestamp: 'asc'
      }
    })
    
    if (periodLogs.length > 0) {
      // 处理温度数据
      const processedData = processTemperatureData(periodLogs)
      
      // 过滤睡眠时段数据
      const sleepData = filterSleepTemperatureData(processedData)
      
      // 验证数据质量
      const validation = validateSleepTemperatureData(sleepData)
      
      if (validation.isValid && validation.avgTemp) {
        historicalPeriods.push(validation.avgTemp)
        console.log(`期间 ${i + 1} 有效，平均温度: ${validation.avgTemp.toFixed(2)}°C`)
      } else {
        console.log(`期间 ${i + 1} 数据质量不足:`, validation.reason)
      }
    }
  }

  // 包含当前期间
  historicalPeriods.push(periodAvgTemp)

  if (historicalPeriods.length >= CALIBRATION_CONFIG.BASELINE_SAMPLE_SIZE) {
    // 可以建立基线
    const baselineValue = historicalPeriods.reduce((sum, avg) => sum + avg, 0) / historicalPeriods.length
    const anchorOffset = calculateAnchorOffset(baselineValue)
    
    const startDate = new Date(endDate)
    startDate.setDate(startDate.getDate() - (periodsNeeded * CALIBRATION_CONFIG.CALIBRATION_PERIOD_DAYS))
    
    const newBaseline = await prisma.user_health_baselines.create({
      data: {
        user_id: userId,
        baseline_type: CALIBRATION_CONFIG.BASELINE_TYPE,
        baseline_value: baselineValue,
        anchor_offset: anchorOffset,
        is_active: true,
        calculation_start_date: startDate,
        calculation_end_date: new Date(endDate),
        sample_size: historicalPeriods.length,
        update_frequency_days: CALIBRATION_CONFIG.BASELINE_UPDATE_DAYS,
        last_updated: new Date()
      }
    })

    // 记录初始偏移量历史
    await recordOffsetHistory(userId, newBaseline.id, anchorOffset, baselineValue, new Date())

    console.log(`成功建立基线: ${baselineValue.toFixed(2)}°C，锚定偏移量: ${anchorOffset.toFixed(2)}°C，基于${historicalPeriods.length}个有效期间`)

    return {
      hasBaseline: true,
      baselineValue,
      anchorOffset,
      isNewBaseline: true
    }
  }

  return {
    hasBaseline: false,
    currentSampleSize: historicalPeriods.length,
    requiredSampleSize: CALIBRATION_CONFIG.BASELINE_SAMPLE_SIZE
  }
}

/**
 * 模块三：校准数据输出（简化版 - 不计算核心体温）
 */
function calculateCalibration(periodAvgTemp: number, baselineTemp: number, anchorOffset: number) {
  return {
    baseline_temp: baselineTemp,                    // 设备测量的基线温度
    period_avg_temp: periodAvgTemp,                 // 设备测量的期间平均温度
    change_from_baseline: periodAvgTemp - baselineTemp, // 设备温度变化
    anchor_offset: anchorOffset,                    // 锚定偏移量（前端用于计算核心体温）
    unit: 'Celsius'
  }
}

// POST - 温度数据校准（基于2天时间跨度）
export async function POST(request: Request) {
  try {
    const body = await request.json()
    const { userId, endDate } = body

    console.log('温度校准请求:', { userId, endDate })

    if (!userId) {
      return NextResponse.json(
        { success: false, error: '缺少用户ID' },
        { status: 400 }
      )
    }

    // 计算时间跨度
    const targetEndDate = endDate ? new Date(endDate) : new Date()
    const targetStartDate = new Date(targetEndDate)
    targetStartDate.setDate(targetStartDate.getDate() - CALIBRATION_CONFIG.CALIBRATION_PERIOD_DAYS)

    console.log(`查询时间范围（${CALIBRATION_CONFIG.CALIBRATION_PERIOD_DAYS}天）:`, {
      startDate: targetStartDate.toISOString().split('T')[0],
      endDate: targetEndDate.toISOString().split('T')[0],
      periodDays: CALIBRATION_CONFIG.CALIBRATION_PERIOD_DAYS
    })

    // 获取指定时间段内的所有温度数据
    const temperatureLogs = await prisma.yh_logs.findMany({
      where: {
        user_id: parseInt(userId),
        type: 'temperature',
        deleted_at: 0,
        timestamp: {
          gte: BigInt(targetStartDate.getTime()),
          lt: BigInt(targetEndDate.getTime())
        }
      },
      orderBy: {
        timestamp: 'asc'
      }
    })

    console.log('查询到的温度记录数量:', temperatureLogs.length)

    if (temperatureLogs.length === 0) {
      return NextResponse.json({
        success: false,
        error: '指定时间段没有温度数据'
      })
    }

    // 模块一：处理和验证温度数据
    // 1. 处理温度数据（复用现有逻辑）
    const processedData = processTemperatureData(temperatureLogs)
    console.log('处理后的温度数据点数量:', processedData.length)

    // 2. 过滤睡眠时段数据
    const sleepTemperatureData = filterSleepTemperatureData(processedData)
    console.log('睡眠时段温度数据点数量:', sleepTemperatureData.length)

    // 3. 验证数据质量
    const validation = validateSleepTemperatureData(sleepTemperatureData)
    
    if (!validation.isValid) {
      return NextResponse.json({
        success: false,
        error: '数据质量不足，无法分析',
        reason: validation.reason
      })
    }

    const periodAvgTemp = validation.avgTemp!
    console.log(`${CALIBRATION_CONFIG.CALIBRATION_PERIOD_DAYS}天期间睡眠时段平均温度:`, periodAvgTemp.toFixed(2), '°C')
    
    // 模块二：基线管理
    const baselineResult = await getOrCreateBaseline(
      parseInt(userId), 
      periodAvgTemp, 
      targetEndDate.toISOString().split('T')[0]
    )

    if (!baselineResult.hasBaseline) {
      const currentSampleSize = baselineResult.currentSampleSize || 0
      const requiredSampleSize = baselineResult.requiredSampleSize || CALIBRATION_CONFIG.BASELINE_SAMPLE_SIZE
      
      return NextResponse.json({
        success: false,
        error: '正在建立个人基线',
        message: `当前样本数量: ${currentSampleSize}/${requiredSampleSize}个有效${CALIBRATION_CONFIG.CALIBRATION_PERIOD_DAYS}天期间`,
        progress: {
          current: currentSampleSize,
          required: requiredSampleSize,
          percentage: Math.round((currentSampleSize / requiredSampleSize) * 100)
        }
      })
    }

    // 模块三：计算校准结果
    const calibrationResult = calculateCalibration(
      periodAvgTemp, 
      baselineResult.baselineValue!, 
      baselineResult.anchorOffset || 0
    )

    return NextResponse.json({
      success: true,
      data: {
        baseline_temp: calibrationResult.baseline_temp,
        period_avg_temp: calibrationResult.period_avg_temp,
        change_from_baseline: calibrationResult.change_from_baseline,
        anchor_offset: calibrationResult.anchor_offset,
        unit: calibrationResult.unit,
        is_baseline_updated: baselineResult.isUpdated || false
      }
    })

  } catch (error) {
    console.error('温度校准失败:', error)
    return NextResponse.json(
      { 
        success: false, 
        error: '温度校准失败',
        message: error instanceof Error ? error.message : '未知错误'
      },
      { status: 500 }
    )
  }
}

// PUT - 获取历史偏移量（用于还原历史温度数据）
export async function PUT(request: Request) {
  try {
    const body = await request.json()
    const { userId, timestamp, startDate, endDate } = body

    if (!userId) {
      return NextResponse.json(
        { success: false, error: '缺少用户ID' },
        { status: 400 }
      )
    }

    // 单个时间点查询
    if (timestamp) {
      const targetTime = new Date(timestamp)
      
      const offsetRecord = await prisma.temperature_offset_history.findFirst({
        where: {
          user_id: parseInt(userId),
          effective_start_date: {
            lte: targetTime
          },
          OR: [
            { effective_end_date: null },
            { effective_end_date: { gt: targetTime } }
          ]
        },
        orderBy: {
          effective_start_date: 'desc'
        }
      })

      if (!offsetRecord) {
        return NextResponse.json({
          success: false,
          error: '指定时间点没有偏移量记录'
        })
      }

      return NextResponse.json({
        success: true,
        data: {
          timestamp: timestamp,
          anchor_offset: offsetRecord.anchor_offset,
          baseline_temp: offsetRecord.baseline_temp,
          effective_start_date: offsetRecord.effective_start_date,
          effective_end_date: offsetRecord.effective_end_date
        }
      })
    }

    // 时间范围查询
    if (startDate && endDate) {
      const offsetRecords = await prisma.temperature_offset_history.findMany({
        where: {
          user_id: parseInt(userId),
          OR: [
            {
              effective_start_date: {
                gte: new Date(startDate),
                lte: new Date(endDate)
              }
            },
            {
              AND: [
                { effective_start_date: { lte: new Date(startDate) } },
                {
                  OR: [
                    { effective_end_date: null },
                    { effective_end_date: { gte: new Date(startDate) } }
                  ]
                }
              ]
            }
          ]
        },
        orderBy: {
          effective_start_date: 'asc'
        }
      })

      return NextResponse.json({
        success: true,
        data: {
          start_date: startDate,
          end_date: endDate,
          offset_records: offsetRecords.map(record => ({
            anchor_offset: record.anchor_offset,
            baseline_temp: record.baseline_temp,
            effective_start_date: record.effective_start_date,
            effective_end_date: record.effective_end_date,
            is_current: record.is_current
          }))
        }
      })
    }

    return NextResponse.json(
      { success: false, error: '缺少时间参数 (timestamp 或 startDate+endDate)' },
      { status: 400 }
    )

  } catch (error) {
    console.error('获取历史偏移量失败:', error)
    return NextResponse.json(
      { 
        success: false, 
        error: '获取历史偏移量失败',
        message: error instanceof Error ? error.message : '未知错误'
      },
      { status: 500 }
    )
  }
}

// GET - 获取用户基线信息
export async function GET(request: Request) {
  try {
    const { searchParams } = new URL(request.url)
    const userId = searchParams.get('userId')

    if (!userId) {
      return NextResponse.json(
        { success: false, error: '缺少用户ID' },
        { status: 400 }
      )
    }

    const baseline = await prisma.user_health_baselines.findFirst({
      where: {
        user_id: parseInt(userId),
        baseline_type: CALIBRATION_CONFIG.BASELINE_TYPE,
        is_active: true
      }
    })

    if (!baseline) {
      return NextResponse.json({
        success: false,
        error: '用户暂无温度基线'
      })
    }

    return NextResponse.json({
      success: true,
      data: {
        baseline_value: baseline.baseline_value,
        anchor_offset: baseline.anchor_offset,
        baseline_type: baseline.baseline_type,
        sample_size: baseline.sample_size,
        update_frequency_days: baseline.update_frequency_days,
        last_updated: baseline.last_updated,
        calculation_period: {
          start_date: baseline.calculation_start_date,
          end_date: baseline.calculation_end_date
        },
        created_at: baseline.created_at
      }
    })

  } catch (error) {
    console.error('获取基线信息失败:', error)
    return NextResponse.json(
      { 
        success: false, 
        error: '获取基线信息失败',
        message: error instanceof Error ? error.message : '未知错误'
      },
      { status: 500 }
    )
  }
}
